<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Stocks</title>
</h:head>
<h:body>
	<header>
		<h1>Stocks yéyé</h1>
	</header>
	<section>
		<h:form>
			<h:dataTable value="#{produitBean.listeProd}" var="product"
				border="1" cellspacing="0">
				<h:column>
					<f:facet name="header">Nom</f:facet>
				#{product.nom}
			</h:column>
				<h:column>
					<f:facet name="header">Prix</f:facet>
					<h:outputFormat value="#{product.prix}">
					</h:outputFormat>€
			</h:column>
				<h:column>
					<f:facet name="header">Quantité</f:facet>
				#{product.qtt}
			</h:column>
				<h:column>
					<f:facet name="header">Total</f:facet>
					<h:outputFormat value="#{product.prix * product.qtt}">
					</h:outputFormat>€
			</h:column>
				<h:column>
					<f:facet name="header">Augmenter qtt</f:facet>
					<h:commandButton value="+" action="#{produitBean.add}">
						<f:setPropertyActionListener target="#{produitBean.idSelected}"
							value="#{product.id}" />
					</h:commandButton>
				</h:column>
				<h:column>
					<f:facet name="header">Diminuer qtt</f:facet>
					<h:commandButton value="-" action="#{produitBean.remove}">
						<f:setPropertyActionListener target="#{produitBean.idSelected}"
							value="#{product.id}" />
					</h:commandButton>
				</h:column>
				<h:column>
					<f:facet name="header">Supprimer produit</f:facet>
					<h:commandButton value="X" action="#{produitBean.delete}">
						<f:setPropertyActionListener target="#{produitBean.idSelected}"
							value="#{product.id}" />
					</h:commandButton>
				</h:column>
			</h:dataTable>
		</h:form>
		<br/><br/><br/>
		<FIELDSET style="width: 260px"><LEGEND>Ajout d'un prod</LEGEND>
		<h:form>
			<div style=" width:100px ; float:left">NOM</div>
			<h:inputText value="#{produitBean.prod.nom}"/>
			<br/>
			<div style=" width:100px ; float:left">PRIX</div>
			<h:inputText value="#{produitBean.prod.prix}"/>
			<br/>
			<div style=" width:100px ; float:left">QUANTITE</div>
			<h:inputText value="#{produitBean.prod.qtt}"/>
			<br/>
			<h:commandButton value="Go !" action="#{produitBean.create}"/>
		</h:form>
		</FIELDSET>
	</section>
</h:body>
</html>